package com.hspedu.newData.dmsxl.数组;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-17 
 * @Version: 1.0
 */

public class LC665非递减数列 {

    // todo
    public boolean checkPossibility(int[] nums) {

        int count = 0;
        int seat = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] > nums[i+1]){
                count++;
                seat = i;
            }
            if (count == 2){
                return false;
            }
        }

        if (seat > 0 && seat < nums.length - 2){

            if (nums[seat] > nums[seat+2] && nums[seat+1] < nums[seat-1]){
                return false;
            }

        }
        return true;
    }
}
